﻿using System;
using System.Linq;
using Stamp_For_Africa_Version_2.Models;

namespace Stamp_For_Africa_Version_2.Repositories
{
	public class CategoryRepository
	{
		private StampsDataContext db = new StampsDataContext();
		//
		// Query Methods

		public IQueryable<Category> FindAllCategories()
		{
			return db.Categories;
		}


		public Category GetCategory(Guid id)
		{
			return db.Categories.SingleOrDefault(d => d.Id == id);
		}

		//
		// Insert/Delete Methods

		public void Add(Category category)
		{
			db.Categories.InsertOnSubmit(category);
		}

		public void Delete(Category category)
		{
			db.Categories.DeleteOnSubmit(category);
		}

		//
		// Persistence

		public void Save()
		{
			db.SubmitChanges();
		}

	}
}